home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / windows / deact102.zip / DEACTV10.WAS < prev    next >
Text File  |  1992-12-03  |  7KB  |  119 lines

  1. ;DEACTV V1.02 Hangup if no activity for x amount of time
  2. ;****************************************************************************
  3. ;*                                                                          *
  4. ;* DEACTV10.WAS                                                             *
  5. ;* Copyright (C) 1992 Datastorm Technologies, Inc.                          *
  6. ;* All rights reserved.                                                     *
  7. ;*                                                                          *
  8. ;* Author: Arthur Yousif                                                    *
  9. ;*                                                                          *
  10. ;* Purpose: Provide a timeout feature when connecting to services           *
  11. ;*          that do not provide it.  After a specified amount of            *
  12. ;*          time with no activity on the port, will disconnect the          *
  13. ;*          session.  The default is 300 seconds (5 minutes) if no          *
  14. ;*          value is entered by user.                                       *
  15. ;*                                                                          *
  16. ;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.   *
  17. ;* DATASTORM makes no warranty of any kind, express or implied, including   *
  18. ;* without limitation, any warranties of merchantability and/or fitness     *
  19. ;* for a particular purpose.  Use of this program is at your own risk.      *
  20. ;*                                                                          *
  21. ;****************************************************************************
  22. ;****************************************************************************
  23. ;*                          Global Variables                                *
  24. ;****************************************************************************
  25. ;*                                                                          *
  26. ;* TimeValue - contains number of seconds to wait                           *
  27. ;* DialogInput - contains value returned by $DIALOG                         *
  28. ;* GetTime - will contain user input value                                  *
  29. ;*                                                                          *
  30. ;****************************************************************************
  31. integer TimeValue=300, DialogInput
  32. string GetTime
  33.  
  34. ;****************************************************************************
  35. ;* MAIN                                                                     *
  36. ;*                                                                          *
  37. ;* Will call the procedure for user input and then wait for the             *
  38. ;* amount of time specified.  If no time is specified, 300 seconds          *
  39. ;* (5 minutes) is used as a default.                                        *
  40. ;*                                                                          *
  41. ;* Calls: GetInput, Deactivate                                              *
  42. ;* Modifies globals: (None)                                                 *
  43. ;****************************************************************************
  44. proc main
  45.  
  46.    GetInput()                            ;get user input
  47.    when quiet TimeValue call Deactivate  ;wait x time of inactivity
  48.                                          ; before deactivating
  49.    while 1                               ;loop
  50.    endwhile
  51.  
  52. endproc
  53.  
  54. ;****************************************************************************
  55. ;* GETINPUT                                                                 *
  56. ;*                                                                          *
  57. ;* Will display a dialog box that prompts the user for the number of        *
  58. ;* seconds to use as a timeout value.                                       *
  59. ;*                                                                          *
  60. ;* Calls: (None)                                                            *
  61. ;* Called by: (None)                                                        *
  62. ;* Modifies globals: TimeValue, DialogInput and GetTime                     *
  63. ;****************************************************************************
  64. proc GetInput
  65.  
  66.    GetTime = "300"     ;initialize to default value
  67.    statmsg ""           ;clear status line
  68.  
  69.    dialogbox 136 87 192 62 6 "Deactivate"             ;display dialog box
  70.       text  6 17 64 8 left "Disconnect after"
  71.       editbox 73 16 24 12 GetTime 5                   ;get user input
  72.       text  109 18 72 8 left "seconds of no activity"
  73.       pushbutton 42 36 40 14 "&Ok" normal default
  74.       pushbutton 112 36 40 14 "&Cancel" cancel
  75.    enddialog
  76.  
  77.    DialogInput = $DIALOG                          ;init dialog variable
  78.    while (DialogInput != 10)&&(DialogInput != 1)  ;loop while Ok & Cancel
  79.                                                   ; buttons not pressed
  80.       DialogInput = $DIALOG
  81.    endwhile
  82.  
  83.    switch DialogInput          ;check for which button was pressed
  84.       case 1                   ;Cancel pressed, so we
  85.          exit                  ; exit the program
  86.       endcase
  87.    endswitch
  88.    destroydlg                  ;remove dialog box and continue with script
  89.  
  90.    strlen GetTime I0           ;get length of input variable
  91.    if I0 > 0                    ;if there is input,
  92.       atoi GetTime TimeValue  ;move & convert value to an int variable
  93.    endif
  94.  
  95. endproc
  96.  
  97. ;****************************************************************************
  98. ;* DEACTIVATE                                                               *
  99. ;*                                                                          *
  100. ;* This procedure is called when the number of seconds of no activity       *
  101. ;* is reached.  Will notify the user that it's disconnecting line           *
  102. ;* due to inactivity, then hangup and notify user that line is              *
  103. ;* disconnected.                                                            *
  104. ;*                                                                          *
  105. ;* Calls: (None)                                                            *
  106. ;* Called by: Main                                                          *
  107. ;* Modifies globals: (None)                                                 *
  108. ;****************************************************************************
  109. proc Deactivate
  110.  
  111.    statmsg "Disconnecting line due to inactivity"  ;disp msg on status line
  112.    hangup
  113.    pause 1
  114.    statmsg "Line disconnected"                     ;disp msg on status line
  115.    exit                                            ;exit script
  116.  
  117. endproc
  118.  
  119.